package com.cdbkj.cloud.pos.utils;

import java.util.Calendar;

/**
 * Created by luozongsheng on 20/04/2018.
 */

public class DateUtils {

    public static int getYear(Calendar calendar){
        return calendar.get(Calendar.YEAR);
    }

    public static String getMonth(Calendar calendar){
        int month = calendar.get(Calendar.MONTH);
        if(month<10){
            return "0"+month;
        }
        return month+"";
    }

    public static String getDay(Calendar calendar){
        int month = calendar.get(Calendar.DAY_OF_MONTH);
        if(month<10){
            return "0"+month;
        }
        return month+"";
    }

    public static String getHour(Calendar calendar){
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        if(hour<10){
            return "0"+hour;
        }
        return hour+"";
    }

    public static String getMinute(Calendar calendar){
        int minute = calendar.get(Calendar.MINUTE);
        if(minute<10){
            return "0"+minute;
        }
        return minute+"";
    }

    public static int getSecond(Calendar calendar){
        return calendar.get(Calendar.SECOND);
    }

    public static String getWeek(Calendar calendar) {
        int i = calendar.get(Calendar.DAY_OF_WEEK);
        switch (i) {
            case 1:
                return "星期日";
            case 2:
                return "星期一";
            case 3:
                return "星期二";
            case 4:
                return "星期三";
            case 5:
                return "星期四";
            case 6:
                return "星期五";
            case 7:
                return "星期六";
            default:
                return "";
        }
    }

}
